package com.example.userp.app.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.userp.app.myapplication.RcycleView.SimpleAdapter;
import com.example.userp.app.myapplication.RcycleView.flexibledivider.VerticalDividerItemDecoration;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class RecycViewActivity extends AppCompatActivity {

    //    @BindView(R.id.main_recyclerview)
    RecyclerView mMainRecyclerview;
    private SimpleAdapter mSimpleAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyc_view);
        ButterKnife.bind(this);
        mMainRecyclerview = findViewById(R.id.main_recyclerview);
        initRV();
    }

    private void initRV() {
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 4);
        LinearLayoutManager gridLayoutManager1 = new LinearLayoutManager(this);
        gridLayoutManager.setOrientation(OrientationHelper.VERTICAL);
        mMainRecyclerview.setLayoutManager(gridLayoutManager);
//        mMainRecyclerview.setLayoutManager(gridLayoutManager1);
//        mMainRecyclerview.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).color(getResources().getColor(R.color.colorAccent)).size(20).margin(20).build());
        mMainRecyclerview.addItemDecoration(new VerticalDividerItemDecoration.Builder(this)
                .color(getResources().getColor(R.color.ss))
                .margin(10, 10)
                .margin(10)
                .showFirstDivider()
                .showLastDivider()
                .showLeftDivider()
                .showRightDivider()
                .size(20)
                .margin(20)
                .build());
//        mMainRecyclerview.addItemDecoration(new RecycleViewDivider(this, gridLayoutManager.HORIZONTAL,10,getResources().getColor(R.color.hs)));
//        mMainRecyclerview.addItemDecoration(new MineRecycleView());
//        mMainRecyclerview.addItemDecoration(new BaseDividerItemDecoration1());
        mSimpleAdapter = new SimpleAdapter(this);
        mMainRecyclerview.setAdapter(mSimpleAdapter);
    }

    @OnClick({R.id.cz1, R.id.cz2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cz1:
                mSimpleAdapter.notifyDataSetChanged();
                break;
            case R.id.cz2:
                break;
        }
    }
}
